#!/bin/bash

# Define the module file path
# MODULE_PATH="/lib/modules/5.10.209-rt89+/kernel/drivers/char/pcie_mcdev.ko"
MODULE_PATH="/lib/modules/4.19.232-rt104+/kernel/drivers/char/pcie_mcdev.ko"

# Check if the module file exists
if [ ! -f "$MODULE_PATH" ]; then
    echo "Error: Module file $MODULE_PATH does not exist!"
    exit 1  # Exit the script with a non-zero status
fi

# If the file exists, insert the module
insmod -f "$MODULE_PATH"

/usr/bin/sleep 0.5
MODULE_TYPE=8
XCAN_ID=0x0801
INTERVAL_MS=1
echo "Start module $MODULE_TYPE ID $XCAN_ID" > /dev/kmsg
# 用法: unit_test_v1 <模块设备号> <测试项编号> <rw> <Mbps> <通道数量> <通道号>... <发送帧数> <帧ID> <帧间隔ms>
# unit_test_v1 canfd 8 1 w 5 1 0 -1 0x01 1
# /usr/bin/unit_test_v1 canfd $MODULE_TYPE 1 rw 5 1 0 -1 $XCAN_ID $INTERVAL_MS &
